﻿using gregn6Lib;
using NursingFormSystem.Common;
using NursingFormSystem.Model;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace NursingFormSystem.NursingPlanForm
{
    public partial class PlanPrint : Form
    {
        #region 变量声明
        private GridppReport Report = new GridppReport();
        NursingFormSystem.WebReference2.FunctionAndPermissions WebScale = new NursingFormSystem.WebReference2.FunctionAndPermissions();
        NursingPlanRecord record = new NursingPlanRecord();
        NursingFormSystem.NurFormsService.NursingForm formService = new NursingFormSystem.NurFormsService.NursingForm();
        string[] PatientInfo;
        int FormID = 0;
        DateTime Start;
        DateTime End;
        #endregion

        #region 构造函数
        public PlanPrint(string[] Patient, int FormId, DateTime StartDate, DateTime EndDate)
        {
            InitializeComponent();
            PatientInfo = Patient;
            FormID = FormId;
            Start = StartDate;
            End = EndDate;
            //载入报表模板数据
            Report.LoadFromFile(System.Windows.Forms.Application.StartupPath + @"\GRFModel\Ydhl_GRF\护理计划单.grf");
            //设置与数据源的连接串，因为在设计时指定的数据库路径是绝对路径。
            Report.ConnectionString = Utility.GetDatabaseConnectionString();
            //连接报表查询SQL打印报表
            string sql = string.Format(@"SELECT  * FROM    NursingPlanRecord r
                                                LEFT JOIN dbo.V_YDHL_PATIENT v ON r.patientId = v.patient_id 
                                                                                  AND r.RecordDate BETWEEN '{0}' AND '{1}'", StartDate, EndDate);
            Report.DetailGrid.Recordset.QuerySQL = sql;
            axGRPrintViewer1.Report = Report;
            //设定查询显示器关联的报表
            axGRPrintViewer1.Report = Report;
        }
        #endregion

        #region 窗体加载启动锐浪报表
        private void PlanPrint_Load(object sender, EventArgs e)
        {
            axGRPrintViewer1.Start();
        }
        #endregion
    }
}
